package com.xiaotao.publisher;


import com.xiaotao.util.RabbitMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

import static com.xiaotao.config.RabbitConfig.ORDER_EXCHANGE;

@Component
@Slf4j
public class TopicPublisher {
    @Resource
    private RabbitTemplate rabbitTemplate;//
    @Resource
    private RabbitMessageUtil rabbitMessageUtil;
    public void  send(String msg,String routingKey){
        rabbitTemplate.setConfirmCallback(rabbitMessageUtil);
        rabbitTemplate.setReturnsCallback(rabbitMessageUtil);
        rabbitTemplate.convertAndSend(ORDER_EXCHANGE, routingKey,msg);
    }
}
